nl.ivojonker.icn.configuration
Class Configuration

java.lang.Object
  extended by nl.ivojonker.icn.configuration.Configuration

public class Configuration
extends java.lang.Object

Manages the creation and retrieval of properties from the (within .jar) configured datasource/tablename. Requires a websphere-application server context as it looks up datasources using the com.ibm.websphere.naming.WsnInitialContextFactory

Author:
nl.ivojonker

Field Summary
private static Configuration _instance
           
private  java.util.ArrayList<ConfigurationEntry> config
           
private static java.lang.String CONFIGTABLENAME
           
private static java.lang.String CREATETABLEQUERY
           
private static java.lang.String DATASOURCEJNDI
           
static java.lang.String DB_COL_DESCRIPTION
           
static java.lang.String DB_COL_EVALFRONTEND
           
static java.lang.String DB_COL_EXPOSEFRONTEND
           
static java.lang.String DB_COL_KEY
           
static java.lang.String DB_COL_VALUE
           
private  java.util.Properties flatConfiguration
           
private static java.util.logging.Logger logger
           
 
Constructor Summary
private Configuration()
          When creating the instance, search the config.properties for the datasource/table name to use.
 
Method Summary
 void createTable()
           
 void dropTable()
          drops the configuration table.
private  javax.sql.DataSource getConfigDS()
          Looks up the datasource in the websphere context.
static Configuration getInstance()
          Gets an instance from the database; will use cache.
static Configuration getInstance(boolean useCache)
          Gets an instance from the database; will use cache.
static Configuration getInstanceSupressExceptions(boolean useCache)
          Always returns a functional ConfigurationObject, even if exceptions occur.
 java.lang.String getProperty(java.lang.String canonicalPropertyName)
          Retrieves a property from the instance; will result null if property not present.
 java.lang.String getProperty(java.lang.String canonicalPropertyName, java.lang.String valueIfNullOrNotPresent)
          Retrieves a property from the instance
protected  java.util.ArrayList<ConfigurationEntry> getRawConfig()
           
protected  void persist(java.util.ArrayList<ConfigurationEntry> props)
          Persists a set of key/values to the database.
private  void refreshConfigFromDB()
          Queries the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static java.util.logging.Logger logger

DATASOURCEJNDI

private static java.lang.String DATASOURCEJNDI

CONFIGTABLENAME

private static java.lang.String CONFIGTABLENAME

CREATETABLEQUERY

private static java.lang.String CREATETABLEQUERY

_instance

private static Configuration _instance

DB_COL_KEY

public static final java.lang.String DB_COL_KEY
See Also:
Constant Field Values

DB_COL_VALUE

public static final java.lang.String DB_COL_VALUE
See Also:
Constant Field Values

DB_COL_EXPOSEFRONTEND

public static final java.lang.String DB_COL_EXPOSEFRONTEND
See Also:
Constant Field Values

DB_COL_EVALFRONTEND

public static final java.lang.String DB_COL_EVALFRONTEND
See Also:
Constant Field Values

DB_COL_DESCRIPTION

public static final java.lang.String DB_COL_DESCRIPTION
See Also:
Constant Field Values

flatConfiguration

private java.util.Properties flatConfiguration

config

private java.util.ArrayList<ConfigurationEntry> config
Constructor Detail

Configuration

private Configuration()
When creating the instance, search the config.properties for the datasource/table name to use.

Method Detail

getInstance

public static Configuration getInstance(boolean useCache)
                                 throws java.sql.SQLException
Gets an instance from the database; will use cache.

Parameters:
useCache - Forces a database roundtrip; updates the current classloader's cache.
Returns:
Throws:
java.sql.SQLException

getInstance

public static Configuration getInstance()
                                 throws java.sql.SQLException
Gets an instance from the database; will use cache.

Returns:
Throws:
java.sql.SQLException

getInstanceSupressExceptions

public static Configuration getInstanceSupressExceptions(boolean useCache)
Always returns a functional ConfigurationObject, even if exceptions occur. Exceptions aren't logged; Advised to use getProperty(key,defaultValueIfNullOrNotPresent).

Parameters:
useCache -
Returns:

refreshConfigFromDB

private void refreshConfigFromDB()
                          throws java.sql.SQLException
Queries the database.

Throws:
java.sql.SQLException

getConfigDS

private javax.sql.DataSource getConfigDS()
Looks up the datasource in the websphere context.

Parameters:
JNDIName -
Returns:

persist

protected void persist(java.util.ArrayList<ConfigurationEntry> props)
                throws java.sql.SQLException
Persists a set of key/values to the database. Deleting the previous settings.

Parameters:
props -
Throws:
java.sql.SQLException

createTable

public void createTable()
                 throws java.sql.SQLException
Throws:
java.sql.SQLException

getProperty

public java.lang.String getProperty(java.lang.String canonicalPropertyName,
                                    java.lang.String valueIfNullOrNotPresent)
Retrieves a property from the instance

Parameters:
canonicalPropertyName -
valueIfNullOrNotPresent -
Returns:

getProperty

public java.lang.String getProperty(java.lang.String canonicalPropertyName)
Retrieves a property from the instance; will result null if property not present.

Parameters:
canonicalPropertyName -
Returns:

getRawConfig

protected java.util.ArrayList<ConfigurationEntry> getRawConfig()

dropTable

public void dropTable()
               throws java.sql.SQLException
drops the configuration table.

Throws:
java.sql.SQLException